home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / X11R4 / cmds / X / ddx / mfb / RCS / mfbimage.c,v < prev    next >
Encoding:
Text File  |  1990-02-15  |  5.4 KB  |  187 lines

  1. head     1.1;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.1
  10. date     90.02.14.19.58.11;  author tve;  state Exp;
  11. branches ;
  12. next     ;
  13.  
  14.  
  15. desc
  16. @Original X11R4 distribution
  17. @
  18.  
  19.  
  20.  
  21. 1.1
  22. log
  23. @Initial revision
  24. @
  25. text
  26. @/***********************************************************
  27. Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
  28. and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  29.  
  30.                         All Rights Reserved
  31.  
  32. Permission to use, copy, modify, and distribute this software and its 
  33. documentation for any purpose and without fee is hereby granted, 
  34. provided that the above copyright notice appear in all copies and that
  35. both that copyright notice and this permission notice appear in 
  36. supporting documentation, and that the names of Digital or MIT not be
  37. used in advertising or publicity pertaining to distribution of the
  38. software without specific, written prior permission.  
  39.  
  40. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  41. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  42. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  43. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  44. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  45. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  46. SOFTWARE.
  47.  
  48. ******************************************************************/
  49. /* $XConsortium: mfbimage.c,v 5.3 89/09/14 16:26:42 rws Exp $ */
  50.  
  51. #include "X.h"
  52.  
  53. #include "windowstr.h"
  54. #include "pixmapstr.h"
  55. #include "scrnintstr.h"
  56. #include "gcstruct.h"
  57.  
  58. #include "mfb.h"
  59. #include "mi.h"
  60. #include "Xmd.h"
  61.  
  62. #include "maskbits.h"
  63.  
  64. #include "servermd.h"
  65.  
  66. /* Put and Get images on a monochrome frame buffer
  67.  *
  68.  *   we do this by creating a temporary pixmap and making its
  69.  * pointer to bits point to the buffer read in from the client.
  70.  * this works because of the padding rules specified at startup
  71.  *
  72.  * Note that CopyArea must know how to copy a bitmap into the server-format
  73.  * temporary pixmap.
  74.  *
  75.  * For speed, mfbPutImage should allocate the temporary pixmap on the stack.
  76.  *
  77.  *     even though an XYBitmap and an XYPixmap have the same
  78.  * format (for this device), PutImage has different semantics for the
  79.  * two.  XYPixmap just does the copy; XYBitmap takes gc.fgPixel for
  80.  * a 1 bit, gc.bgPixel for a 0 bit, which we notice is exactly
  81.  * like CopyPlane.
  82.  *
  83.  *   written by drewry, september 1986
  84.  */
  85.  
  86.  
  87. /*ARGSUSED*/
  88. void
  89. mfbPutImage(dst, pGC, depth, x, y, w, h, leftPad, format, pImage)
  90.     DrawablePtr dst;
  91.     GCPtr    pGC;
  92.     int        depth, x, y, w, h;
  93.     int leftPad;
  94.     unsigned int format;
  95.     int     *pImage;
  96. {
  97.     PixmapRec    FakePixmap;
  98.  
  99.     if (!(pGC->planemask & 1))
  100.     return;
  101.  
  102.     /* 0 may confuse CreatePixmap, and will sometimes be
  103.        passed by the mi text code
  104.     */
  105.     if ((w == 0) || (h == 0))
  106.     return;
  107.  
  108.     FakePixmap.drawable.type = DRAWABLE_PIXMAP;
  109.     FakePixmap.drawable.class = 0;
  110.     FakePixmap.drawable.pScreen = dst->pScreen;
  111.     FakePixmap.drawable.depth = 1;
  112.     FakePixmap.drawable.bitsPerPixel = 1;
  113.     FakePixmap.drawable.id = 0;
  114.     FakePixmap.drawable.serialNumber = NEXT_SERIAL_NUMBER;
  115.     FakePixmap.drawable.x = 0;
  116.     FakePixmap.drawable.y = 0;
  117.     FakePixmap.drawable.width = w+leftPad;
  118.     FakePixmap.drawable.height = h;
  119.     FakePixmap.devKind = PixmapBytePad(FakePixmap.drawable.width, 1);
  120.     FakePixmap.refcnt = 1;
  121.     FakePixmap.devPrivate.ptr = (pointer)pImage;
  122.     ((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->fExpose = FALSE;
  123.     if (format != XYBitmap)
  124.     (*pGC->ops->CopyArea)(&FakePixmap, dst, pGC, leftPad, 0, w, h, x, y);
  125.     else
  126.     (*pGC->ops->CopyPlane)(&FakePixmap, dst, pGC, leftPad, 0, w, h, x, y, 1);
  127.     ((mfbPrivGC*)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->fExpose = TRUE;
  128. }
  129.  
  130.  
  131. /*
  132.  * pdstLine points to space allocated by caller, which he can do since
  133.  * he knows dimensions of the pixmap
  134.  * we can call mfbDoBitblt because the dispatcher has promised not to send us
  135.  * anything that would require going over the edge of the screen.
  136.  *
  137.  *    XYPixmap and ZPixmap are the same for mfb.
  138.  *    For any planemask with bit 0 == 0, just fill the dst with 0.
  139.  */
  140. /*ARGSUSED*/
  141. void
  142. mfbGetImage( pDrawable, sx, sy, w, h, format, planeMask, pdstLine)
  143.     DrawablePtr pDrawable;
  144.     int        sx, sy, w, h;
  145.     unsigned int format;
  146.     unsigned long planeMask;
  147.     pointer    pdstLine;
  148. {
  149.     PixmapRec FakePixmap;
  150.     BoxRec box;
  151.     DDXPointRec ptSrc;
  152.     RegionRec rgnDst;
  153.  
  154.     if (planeMask & 0x1)
  155.     {
  156.     FakePixmap.drawable.type = DRAWABLE_PIXMAP;
  157.     FakePixmap.drawable.class = 0;
  158.     FakePixmap.drawable.pScreen = pDrawable->pScreen;
  159.     FakePixmap.drawable.depth = 1;
  160.     FakePixmap.drawable.bitsPerPixel = 1;
  161.     FakePixmap.drawable.id = 0;
  162.     FakePixmap.drawable.serialNumber = NEXT_SERIAL_NUMBER;
  163.     FakePixmap.drawable.x = 0;
  164.     FakePixmap.drawable.y = 0;
  165.     FakePixmap.drawable.width = w;
  166.     FakePixmap.drawable.height = h;
  167.     FakePixmap.devKind = PixmapBytePad(w, 1);
  168.     FakePixmap.refcnt = 1;
  169.     FakePixmap.devPrivate.ptr = pdstLine;
  170.         ptSrc.x = sx + pDrawable->x;
  171.         ptSrc.y = sy + pDrawable->y;
  172.         box.x1 = 0;
  173.         box.y1 = 0;
  174.         box.x2 = w;
  175.         box.y2 = h;
  176.         (*pDrawable->pScreen->RegionInit)(&rgnDst, &box, 1);
  177.         mfbDoBitblt(pDrawable, (DrawablePtr)&FakePixmap,
  178.             GXcopy, &rgnDst, &ptSrc);
  179.         (*pDrawable->pScreen->RegionUninit)(&rgnDst);
  180.     }
  181.     else
  182.     {
  183.     bzero((char *)pdstLine, PixmapBytePad(w, 1) * h);
  184.     }
  185. }
  186. @
  187.